{if $params.action=="acl"}

	<script language="javascript">
	
		$(document).ready(function () {
			
			$("form input[type=submit]").button();
			
			$(":checkbox[name='GrRoles']").click(function () {
				$(":checkbox[name='acl["+this.value+"][]']").attr("checked",this.checked);
			});
			
			$(":checkbox[name='GrResources']").click(function () {
				$(":checkbox[name^='acl'][value="+this.value+"]").attr("checked",this.checked);
			});
			
			$(".allcontent table:first").css({ position:'fixed',top:0,width:$("form table").width() }).hide();
			
		});
		
		$(window).scroll(function(){
			if($(window).scrollTop() >= $("form table").offset().top) {
				$(".allcontent table:first").show();
			} else {
				$(".allcontent table:first").hide();
			}
		});
		
	</script>
	
	<table class="ui-widget-content noborder">
		<tr class="ui-widget-header">
			<th colspan="2" class="pd4">&nbsp;</th>
			{foreach from=$Roles item=data}
				<th width="10%" class="pd4"><b>{$data.rolename}</b></th>
			{/foreach}
		</tr>
	</table>
	
	<form method="POST">
	
		<table>
			<tr class="ui-widget-header">
				<th colspan="2" class="pd4">&nbsp;</th>
				{foreach from=$Roles item=data}
					<th width="10%" class="pd4"><b>{$data.rolename}</b></th>
				{/foreach}
			</tr>
			<tr align="center">
				<td colspan="2" class="pd4">&nbsp;</td>
				{foreach from=$Roles item=data}
					<td class="pd4"><input type="checkbox" value="{$data.roleid}" name="GrRoles" title="{_('Выбрать всю колонку')}" /></td>
				{/foreach}
			</tr>
			
			{foreach from=$Resources key=module item=mdata}
				<tr>
					<td colspan="{math equation='x+2' x=$Roles|@count}" class="pd4">
						<h2>{if $module=="default"}{_('Сайт')}{else}{_('Административная панель')}{/if} ({$module})</h2>
					</td>
				</tr>
				{foreach from=$mdata.controllers key=controller item=cdata}
					<tr class="ui-widget-header">
						<td colspan="{math equation='x+2' x=$Roles|@count}" class="pd4">
							{if $cdata.resourcename}{$cdata.resourcename} ({$controller}){else}{$controller}{/if}
						</td>
					</tr>
					{foreach from=$cdata.actions key=action item=adata}
						<tr class="ui-state-default">
							<td class="pd4">
								{if $adata.resourcename}{$adata.resourcename} ({$action}){else}{$action}{/if}
							</td>
							<td class="pd4" align="center" class="ui-widget-content noborder"><input type="checkbox" value="{$adata.resourceid}" name="GrResources" title="Выбрать всю строку" /></td>
                            {foreach from=$Roles item=data}
								<td align="center">
									<input type="checkbox" name="acl[{$data.roleid}][]" value="{$adata.resourceid}" {if $AclList[$data.roleid][$adata.resourceid]}checked{/if} />
								</td>
							{/foreach}
						</tr>
					{/foreach}
				{/foreach}
			{/foreach}
		</table>
		
		<p align="center"><input type="submit" value="{_('Внести изменения')}" /></p>
		
	</form>

{/if}


{if $params.action=="edit"}
	{$Form}
{/if}